package com.example.jvm.jvm05.lesson31;

import lombok.extern.slf4j.Slf4j;
import org.openjdk.jol.datamodel.X86_64_DataModel;
import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.layouters.HotSpotLayouter;
import org.openjdk.jol.layouters.Layouter;
import org.openjdk.jol.vm.VM;

/**
 * @Date 2024-02-25
 * @Author Jonathan
 */
@Slf4j
public class TestIntegerMarkWord {
    public static void main(String[] args) {
        MyStudent a = new MyStudent();
//        Integer a = new Integer(10);
//        Student a = new Student();
        Layouter l;
        l = new HotSpotLayouter(new X86_64_DataModel());
//        MyObject o = new MyObject();
        System.out.println(VM.current().details());
//        log.info("十六进制：{}", Integer.toHexString(o.hashCode()));
        new Thread(() -> {
            synchronized (a) {
                log.info("threadId:{}", Thread.currentThread().getId());
                log.info(ClassLayout.parseInstance(a, l).toPrintable());
                log.info("hashCode:{}", a.hashCode());
                log.info(ClassLayout.parseInstance(a, l).toPrintable());
            }
        }).start();
    }
}
